﻿package com.amcharts
{
	import com.amcharts.axes.*;
	import com.amcharts.chartClasses.*;
	import com.amcharts.events.*;
	import com.amcharts.utils.*;
	import flash.display.*;
	import flash.events.*;
	import mx.collections.*;
	import mx.core.*;
	import mx.effects.easing.*;
	import mx.events.*;
	import mx.styles.*;

	public class AmSerialChart extends AmRectangularChart
	{
		protected var _endTime:Number;
		protected var _columnSpacing:Number;
		protected var _end:Number;
		protected var _columnsMaskOld:PlotArea;
		protected var _firstTime:Number;
		protected var _seriesIdField:String;
		protected var _tempEndValue:String;
		protected var _tempStartValue:String;
		protected var _maxSelectedTime:Number;
		protected var _columnsArray:Array;
		protected var _start:Number;
		protected var _columnsContainer:UIComponent;
		protected var _rotate:Boolean;
		protected var _tempEndIndex:Number;
		protected var _categoryAxis:CategoryAxis;
		protected var _columnCount:Number;
		protected var _tempStartIndex:Number;
		protected var _columnsContainerOld:UIComponent;
		protected var _columnsAboveLines:Boolean=false;
		protected var _columnsMask:PlotArea;
		protected var _zoomOutOnDataUpdate:Boolean=true;
		protected var _tempStartDate:Date;
		protected var _startTime:Number;
		protected var _lastTime:Number;
		protected var _tempEndDate:Date;
		protected var _maxSelectedSeries:Number;
		static const VERSION:String="1.8.3.1";
		private static var stylesInited:Boolean=initStyles();

		public function AmSerialChart()
		{
			_chartType="serial";
			if (!_categoryAxis)
			{
				categoryAxis=new CategoryAxis();
			}
			return;
		} // end function

		override public function highlightGraph(param1:AmGraph):void
		{
			var _loc_4:Number=NaN;
			super.highlightGraph(param1);
			var _loc_2:Number=0.05;
			if (_legend)
			{
				_loc_2=_legend.getStyle("rollOverGraphAlpha");
			}
			var _loc_3:*=_columnsArray.length;
			if (_loc_3 > 0)
			{
				_loc_4=0;
				while (_loc_4 < _loc_3)
				{

					_columnsArray[_loc_4].column.alpha=_loc_2;
					_loc_4=_loc_4 + 1;
				}
				_loc_3=param1.columns.length;
				_loc_4=0;
				while (_loc_4 < _loc_3)
				{

					param1.columns[_loc_4].alpha=1;
					_loc_4=_loc_4 + 1;
				}
			}
			return;
		} // end function

		protected function removeOld():void
		{
			if (_columnsContainerOld)
			{
				Utils.removeChildren(_columnsContainerOld);
				if (_columnsContainerOld.parent == this)
				{
					this.removeChild(_columnsContainerOld);
				}
				_columnsContainerOld=undefined;
			}
			return;
		} // end function

		public function dispatchCursorEvent(param1:Number):void
		{
			var _loc_4:AmGraph=null;
			var _loc_5:SerialDataItem=null;
			var _loc_6:GraphDataItem=null;
			var _loc_2:*=_graphs.length;
			var _loc_3:Number=0;
			while (_loc_3 < _loc_2)
			{

				_loc_4=_graphs[_loc_3];
				_loc_4.currentDataItem=undefined;
				if (param1 > -1)
				{
				}
				if (param1 < _chartDataProvider.length)
				{
					_loc_5=_chartDataProvider.getItemAt(param1) as SerialDataItem;
					_loc_6=
						_loc_5.charts[this.id].axes[_loc_4.valueAxis.id].graphs[_loc_4.id];
					_loc_4.currentDataItem=_loc_6;
				}
				_loc_3=_loc_3 + 1;
			}
			dispatchEvent(new Event("legendValuesChanged"));
			return;
		} // end function

		override protected function updateTrendLines():void
		{
			var _loc_3:TrendLine=null;
			super.updateTrendLines();
			var _loc_1:*=_trendLines.length;
			var _loc_2:Number=0;
			while (_loc_2 < _loc_1)
			{

				_loc_3=_trendLines[_loc_2];
				if (!_loc_3.valueAxis)
				{
					_loc_3.valueAxis=_valueAxes[0];
				}
				_loc_3.categoryAxis=_categoryAxis;
				_graphsContainer.addChild(_loc_3);
				_loc_2=_loc_2 + 1;
			}
			return;
		} // end function

		override protected function updateData():void
		{
			var _loc_3:Sort=null;
			var _loc_4:ValueAxis=null;
			var _loc_5:AmGraph=null;
			var _loc_6:Number=NaN;
			var _loc_7:Number=NaN;
			var _loc_8:Number=NaN;
			var _loc_9:Number=NaN;
			var _loc_10:Number=NaN;
			super.updateData();
			removeOld();
			_columnsContainerOld=_columnsContainer;
			createColumnsContainer();
			_dataParser.charts=[this];
			_dataParser.categoryField=_categoryField;
			_dataParser.seriesIdField=_seriesIdField;
			_dataParser.minPeriod=_categoryAxis.minPeriod;
			_chartDataProvider=
				_dataParser.parseSerialData(_dataProvider, _categoryAxis.firstDayOfWeek);
			if (_categoryAxis.parseDates)
			{
				_loc_3=new Sort();
				_loc_3.fields=[new SortField("time", true, false, true)];
				_chartDataProvider.sort=_loc_3;
				_chartDataProvider.refresh();
			}
			_categoryAxis.dataProvider=_chartDataProvider;
			_categoryAxis.valuesContainer=_valuesContainer;
			setAxisRenderers(_categoryAxis);
			if (_chartScrollbar)
			{
				_chartScrollbar.dataProvider=_chartDataProvider;
				_chartScrollbar.chart=this;
			}
			if (_chartCursor)
			{
				_chartCursor.hideCursor();
				_chartCursor.dataProvider=_chartDataProvider;
				_chartCursor.categoryAxis=_categoryAxis;
			}
			var _loc_1:*=_valueAxes.length;
			var _loc_2:Number=0;
			while (_loc_2 < _loc_1)
			{

				_loc_4=_valueAxes[_loc_2];
				_loc_4.dataProvider=_chartDataProvider;
				_loc_2=_loc_2 + 1;
			}
			_columnCount=countColumns();
			_loc_1=_graphs.length;
			_loc_2=0;
			while (_loc_2 < _loc_1)
			{

				_loc_5=_graphs[_loc_2];
				_loc_5.categoryAxis=_categoryAxis;
				_loc_5.chartDataProvider=_chartDataProvider;
				_loc_5.columnCount=_columnCount;
				_loc_2=_loc_2 + 1;
			}
			if (_chartDataProvider.length > 0)
			{
				_loc_6=_chartDataProvider.length - 1;
				if (_categoryAxis.parseDates)
				{
				}
				if (!_categoryAxis.equalSpacing)
				{
					_loc_9=_chartDataProvider.getItemAt(_loc_6).time;
					_loc_10=_chartDataProvider.getItemAt(0).time;
					_loc_7=_startTime;
					_loc_8=_endTime;
					if (!isNaN(_loc_7))
					{
						isNaN(_loc_7);
					}
					if (isNaN(_loc_8))
					{
						_loc_7=_loc_10;
						_loc_8=_loc_9;
					}
				}
				else
				{
					_loc_7=_start;
					_loc_8=_end;
					if (!isNaN(_loc_7))
					{
						isNaN(_loc_7);
					}
					if (isNaN(_loc_8))
					{
						_loc_7=0;
						_loc_8=_loc_6;
					}
				}
				_start=undefined;
				_end=undefined;
				_startTime=undefined;
				_endTime=undefined;
				zoom(_loc_7, _loc_8);
			}
			else
			{
				removeOld();
			}
			return;
		} // end function

		override protected function updateGraphs():void
		{
			var _loc_4:AmGraph=null;
			super.updateGraphs();
			_columnsContainer.x=_marginLeft;
			_columnsContainer.y=_marginTop;
			_columnSpacing=getStyle("columnSpacing");
			var _loc_1:*=getStyle("columnWidth");
			_columnsArray=new Array();
			var _loc_2:*=_graphs.length;
			var _loc_3:Number=0;
			while (_loc_3 < _loc_2)
			{

				_loc_4=_graphs[_loc_3];
				_loc_4.chartType="serial";
				_loc_4.rotate=_rotate;
				_loc_4.columnWidth=_loc_1;
				_loc_4.removeEventListener("ColumnsArrayUpdated", invalidateColumns);
				_loc_4.addEventListener("ColumnsArrayUpdated", invalidateColumns);
				_loc_3=_loc_3 + 1;
			}
			return;
		} // end function

		public function set maxSelectedTime(param1:Number):void
		{
			_maxSelectedTime=param1;
			invalidateDisplayList();
			return;
		} // end function

		override protected function createChildren():void
		{
			super.createChildren();
			if (_mouseWheelEnabled)
			{
			}
			if (_chartScrollbar)
			{
				this.removeEventListener(MouseEvent.MOUSE_WHEEL, mouseWheelHandler);
				this.addEventListener(MouseEvent.MOUSE_WHEEL, mouseWheelHandler);
			}
			_columnsMask=new PlotArea();
			this.addChild(_columnsMask);
			createColumnsContainer();
			return;
		} // end function

		public function get columnsAboveLines():Boolean
		{
			return _columnsAboveLines;
		} // end function

		protected function invalidateColumns(event:Event):void
		{
			addColumns();
			return;
		} // end function

		public function zoomToCategoryValues(param1:String, param2:String):void
		{
			updateScrollbar();
			if (!_dataProviderChanged)
			{
			}
			if (_dataChanged)
			{
				_tempStartValue=param1;
				_tempEndValue=param2;
				this.addEventListener(AmChartEvent.DATA_UPDATED,
					handleDelayedZoomToCategoryValues);
			}
			else
			{
				zoom(getCategoryIndexByValue(param1), getCategoryIndexByValue(param2));
			}
			return;
		} // end function

		override protected function updateCategoryAxis():void
		{
			super.updateCategoryAxis();
			_categoryAxis.chart=this;
			_categoryAxis.x=_marginLeft;
			_categoryAxis.y=_marginTop;
			_categoryAxis.width=_plotAreaWidth;
			_categoryAxis.height=_plotAreaHeight;
			_categoryAxis.rotate=_rotate;
			_categoryAxis.visibleAxisWidth=_plotAreaWidth;
			_categoryAxis.visibleAxisHeight=_plotAreaHeight;
			_categoryAxis.dx=_dx;
			_categoryAxis.dy=_dy;
			return;
		} // end function

		override public function removeGraph(param1:AmGraph):void
		{
			Utils.removeChildren(_columnsContainer);
			super.removeGraph(param1);
			return;
		} // end function

		public function get seriesIdField():String
		{
			return _seriesIdField;
		} // end function

		public function get startDate():Date
		{
			if (isNaN(_startTime))
			{
				isNaN(_startTime);
			}
			if (!isNaN(_start))
			{
			}
			if (this.categoryAxis.parseDates)
			{
				return new Date(_chartDataProvider.getItemAt(_start).time);
			}
			return new Date(_startTime);
		} // end function

		override protected function updateDepths():void
		{
			super.updateDepths();
			this.setChildIndex(_plotArea, 0);
			this.setChildIndex(_valueAxesContainer, 1);
			this.setChildIndex(_categoryAxis, 2);
			if (_columnsAboveLines)
			{
				this.setChildIndex(_graphsContainer, (this.numChildren - 1));
				this.setChildIndex(_columnsContainer, (this.numChildren - 1));
			}
			else
			{
				this.setChildIndex(_columnsContainer, (this.numChildren - 1));
				this.setChildIndex(_graphsContainer, (this.numChildren - 1));
			}
			this.setChildIndex(_grid0, (this.numChildren - 1));
			this.setChildIndex(_valuesContainer, (this.numChildren - 1));
			this.setChildIndex(_labelsContainer, (this.numChildren - 1));
			if (_chartCursor)
			{
				this.setChildIndex(_chartCursor, (this.numChildren - 1));
			}
			if (_chartScrollbar)
			{
				this.setChildIndex(_chartScrollbar, (this.numChildren - 1));
			}
			this.setChildIndex(DisplayObject(_zoomOutButton), (this.numChildren - 1));
			this.setChildIndex(_balloon, (this.numChildren - 1));
			return;
		} // end function

		public function set columnsAboveLines(param1:Boolean):void
		{
			_columnsAboveLines=param1;
			invalidateDisplayList();
			return;
		} // end function

		public function set categoryField(param1:String):void
		{
			_categoryField=param1;
			_dataChanged=true;
			invalidateProperties();
			invalidateDisplayList();
			return;
		} // end function

		public function get endDate():Date
		{
			if (isNaN(_endTime))
			{
				isNaN(_endTime);
			}
			if (!isNaN(_end))
			{
			}
			if (this.categoryAxis.parseDates)
			{
				return new Date(_chartDataProvider.getItemAt(_end).time);
			}
			return new Date(_endTime);
		} // end function

		protected function createColumnsContainer():void
		{
			_columnsContainer=new UIComponent();
			this.addChild(_columnsContainer);
			_columnsContainer.mask=_columnsMask;
			return;
		} // end function

		override protected function createChart():void
		{
			super.createChart();
			return;
		} // end function

		override protected function updateChartCursor():void
		{
			super.updateChartCursor();
			if (_chartCursor)
			{
				_chartCursor.rotate=_rotate;
				_chartCursor.graphs=_graphs;
				_chartCursor.chart=this;
			}
			return;
		} // end function

		protected function timeZoom(param1:Number, param2:Number):void
		{
			var _loc_3:Number=NaN;
			var _loc_4:Number=NaN;
			if (!isNaN(_maxSelectedTime))
			{
				if (param2 != _endTime)
				{
					if (param2 - param1 > _maxSelectedTime)
					{
						param1=param2 - _maxSelectedTime;
						_updateScrollbar=true;
					}
				}
				if (param1 != _startTime)
				{
					if (param2 - param1 > _maxSelectedTime)
					{
						param2=param1 + _maxSelectedTime;
						_updateScrollbar=true;
					}
				}
			}
			if (param1 == _startTime)
			{
			}
			if (param2 != _endTime)
			{
				if (_chartDataProvider.length > 0)
				{
					_loc_3=_categoryAxis.minDuration;
					_firstTime=_chartDataProvider.getItemAt(0).time;
					_lastTime=
						_chartDataProvider.getItemAt((_chartDataProvider.length - 1)).time;
					if (!param1)
					{
						param1=_firstTime;
						if (!isNaN(_maxSelectedTime))
						{
							param1=_lastTime - _maxSelectedTime;
						}
					}
					if (!param2)
					{
						param2=_lastTime;
					}
					if (param1 > _lastTime)
					{
						param1=_lastTime;
					}
					if (param2 < _firstTime)
					{
						param2=_firstTime;
					}
					if (param1 < _firstTime)
					{
						param1=_firstTime;
					}
					if (param2 > _lastTime)
					{
						param2=_lastTime;
					}
					if (param2 < param1)
					{
						param2=param1 + _loc_3;
					}
					_startTime=param1;
					_endTime=param2;
					_loc_4=_chartDataProvider.length - 1;
					_start=
						Utils.getClosestIndex(_chartDataProvider, "time", _startTime,
						true, 0, _loc_4);
					_end=
						Utils.getClosestIndex(_chartDataProvider, "time", _endTime, false,
						_start, _loc_4);
					_categoryAxis.zoom(_start, _end);
					_categoryAxis.timeZoom(_startTime, _endTime);
					_categoryAxis.validateNow();
					_start=Utils.fitToBounds(_start, 0, _loc_4);
					_end=Utils.fitToBounds(_end, 0, _loc_4);
					zoomAxesAndGraphs();
					zoomScrollbar();
					if (param1 == _firstTime)
					{
					}
					if (param2 != _lastTime)
					{
						_zoomOutButton.visible=true;
					}
					else
					{
						_zoomOutButton.visible=false;
					}
					callLater(dispatchTimeZoomEvent);
				}
			}
			return;
		} // end function

		public function set seriesIdField(param1:String):void
		{
			_seriesIdField=param1;
			_dataChanged=true;
			invalidateProperties();
			invalidateDisplayList();
			return;
		} // end function

		override protected function handleZoomOut(event:MouseEvent):void
		{
			if (_zoomOutPressed)
			{
				if (_chartScrollbar)
				{
					_chartScrollbar.stopTween();
				}
				zoomOut();
				_zoomOutPressed=false;
			}
			return;
		} // end function

		protected function handleDelayedZoomToCategoryValues(event:AmChartEvent):void
		{
			this.removeEventListener(AmChartEvent.DATA_UPDATED,
				handleDelayedZoomToCategoryValues);
			zoomToCategoryValues(_tempStartValue, _tempEndValue);
			return;
		} // end function

		override protected function dataChangedHandler(event:CollectionEvent):void
		{
			super.dataChangedHandler(event);
			if (_zoomOutOnDataUpdate)
			{
				_start=NaN;
				_startTime=NaN;
				_end=NaN;
				_endTime=NaN;
			}
			return;
		} // end function

		public function updateScrollbar():void
		{
			_updateScrollbar=true;
			if (_chartScrollbar)
			{
				_chartScrollbar.stopTween();
			}
			return;
		} // end function

		protected function handleLogFailed(event:ValueAxisEvent):void
		{
			_columnsContainerOld=_columnsContainer;
			removeOld();
			return;
		} // end function

		public function get rotate():Boolean
		{
			return _rotate;
		} // end function

		override protected function updateValueAxes():void
		{
			var _loc_3:ValueAxis=null;
			super.updateValueAxes();
			var _loc_1:*=_valueAxes.length;
			var _loc_2:Number=0;
			while (_loc_2 < _loc_1)
			{

				_loc_3=_valueAxes[_loc_2];
				_loc_3.rotate=_rotate;
				if (_categoryAxis.startOnAxis)
				{
				}
				if (_categoryAxis.parseDates)
				{
					_loc_3.expandMinMax=true;
				}
				_loc_3.removeEventListener(ValueAxisEvent.LOGARITHMIC_AXIS_FAILED,
					handleLogFailed);
				_loc_3.addEventListener(ValueAxisEvent.LOGARITHMIC_AXIS_FAILED,
					handleLogFailed);
				_loc_2=_loc_2 + 1;
			}
			return;
		} // end function

		public function zoomToIndexes(param1:Number, param2:Number):void
		{
			updateScrollbar();
			if (!_dataProviderChanged)
			{
			}
			if (_dataChanged)
			{
				_tempStartIndex=param1;
				_tempEndIndex=param2;
				this.addEventListener(AmChartEvent.DATA_UPDATED,
					handleDelayedZoomToIndexes);
			}
			else
			{
				if (param1 < 0)
				{
					param1=0;
				}
				if (param2 > (_chartDataProvider.length - 1))
				{
					param2=_chartDataProvider.length - 1;
				}
				if (_categoryAxis.parseDates)
				{
				}
				if (!_categoryAxis.equalSpacing)
				{
					zoom(_chartDataProvider.getItemAt(param1).time,
						_chartDataProvider.getItemAt(param2).time);
				}
				else
				{
					zoom(param1, param2);
				}
			}
			return;
		} // end function

		public function get lookupTable():Object
		{
			return _dataParser.lookupTable;
		} // end function

		public function get maxSelectedSeries():Number
		{
			return _maxSelectedSeries;
		} // end function

		public function zoomToDates(param1:Date, param2:Date):void
		{
			var _loc_3:Number=NaN;
			var _loc_4:Number=NaN;
			updateScrollbar();
			if (!_dataProviderChanged)
			{
			}
			if (_dataChanged)
			{
				_tempStartDate=param1;
				_tempEndDate=param2;
				this.addEventListener(AmChartEvent.DATA_UPDATED, handleDelayedZoomToDates);
			}
			else if (_categoryAxis.equalSpacing)
			{
				_loc_3=
					Utils.getClosestIndex(_chartDataProvider, "time", param1.getTime(),
					true, 0, _chartDataProvider.length);
				_loc_4=
					Utils.getClosestIndex(_chartDataProvider, "time", param2.getTime(),
					false, 0, _chartDataProvider.length);
				zoom(_loc_3, _loc_4);
			}
			else
			{
				zoom(param1.getTime(), param2.getTime());
			}
			return;
		} // end function

		protected function handleDelayedZoomToIndexes(event:AmChartEvent):void
		{
			this.removeEventListener(AmChartEvent.DATA_UPDATED,
				handleDelayedZoomToIndexes);
			zoomToIndexes(_tempStartIndex, _tempEndIndex);
			return;
		} // end function

		override protected function addAxesListeners():void
		{
			var _loc_1:String=null;
			var _loc_2:String=null;
			super.addAxesListeners();
			if (_autoMargins)
			{
				if (!_categoryAxis.inside)
				{
				}
				if (!_categoryAxis.ignoreAxisWidth)
				{
					_categoryAxis.rotate=_rotate;
					_loc_1=_categoryAxis.position;
					_loc_2="margin" + Utils.capitalizeFirst(_loc_1);
					this.setStyle(_loc_2, 0);
					_categoryAxis.removeEventListener(AxisEvent.AXIS_WIDTH_CHANGED,
						handleAxisWidthChange);
					_categoryAxis.addEventListener(AxisEvent.AXIS_WIDTH_CHANGED,
						handleAxisWidthChange);
				}
			}
			return;
		} // end function

		public function zoomOut():void
		{
			callLater(delayedZoomout);
			return;
		} // end function

		override protected function updateMargins():void
		{
			var _loc_1:String=null;
			super.updateMargins();
			_scrollbarHeight=0;
			if (_chartScrollbar)
			{
				_chartScrollbar.rotate=_rotate;
				if (_rotate)
				{
					_scrollbarHeight=_chartScrollbar.width;
				}
				else
				{
					_scrollbarHeight=_chartScrollbar.height;
				}
				if (_rotate)
				{
					if (_categoryAxis.position != "bottom")
					{
					}
					if (_categoryAxis.position == "left")
					{
						_scrollbarPosition="bottom";
					}
					else
					{
						_scrollbarPosition="top";
					}
				}
				else
				{
					if (_categoryAxis.position != "top")
					{
					}
					if (_categoryAxis.position == "right")
					{
						_scrollbarPosition="bottom";
					}
					else
					{
						_scrollbarPosition="top";
					}
				}
				if (_scrollbarPosition == "top")
				{
					if (_rotate)
					{
						_marginLeft=_marginLeft + _scrollbarHeight;
					}
					else
					{
						_marginTop=_marginTop + _scrollbarHeight;
					}
				}
				else if (_rotate)
				{
					_marginRight=_marginRight + _scrollbarHeight;
				}
				else
				{
					_marginBottom=_marginBottom + _scrollbarHeight;
				}
			}
			return;
		} // end function

		override public function set dataProvider(param1:Object):void
		{
			super.dataProvider=param1;
			_start=NaN;
			_startTime=NaN;
			_end=NaN;
			_endTime=NaN;
			updateScrollbar();
			return;
		} // end function

		public function set categoryAxis(param1:CategoryAxis):void
		{
			if (_categoryAxis)
			{
				_categoryAxis.destroy();
				removeChild(_categoryAxis);
			}
			_categoryAxis=param1;
			_categoryAxis.id="main";
			addChild(_categoryAxis);
			_dataChanged=true;
			invalidateProperties();
			return;
		} // end function

		override protected function designMode():void
		{
			if (!_categoryAxis)
			{
				categoryAxis=new CategoryAxis();
			}
			if (!_categoryAxis.parseDates)
			{
				dataProvider=
					new ArrayCollection([{year: "sample 1", value: 1},
					{year: "sample 2", value: 3}, {year: "sample 3", value: 6}]);
			}
			else
			{
				_categoryAxis.minPeriod="DD";
				dataProvider=
					new ArrayCollection([{year: new Date(2010, 0, 1), value: 1},
					{year: new Date(2010, 0, 2), value: 3},
					{year: new Date(2010, 0, 3), value: 6}]);
			}
			categoryField="year";
			_autoMargins=false;
			graphs=new Array();
			var _loc_1:*=new AmGraph();
			_loc_1.type="column";
			_loc_1.setStyle("fillAlphas", [1]);
			_loc_1.valueField="value";
			this.setStyle("startEffect", Exponential.easeOut);
			this.setStyle("startDuration", 0);
			addGraph(_loc_1);
			return;
		} // end function

		public function get zoomOutOnDataUpdate():Boolean
		{
			return _zoomOutOnDataUpdate;
		} // end function

		public function get maxSelectedTime():Number
		{
			return _maxSelectedTime;
		} // end function

		public function get startIndex():Number
		{
			return _start;
		} // end function

		override protected function handleCursorZoom(event:CursorEvent):void
		{
			_updateScrollbar=true;
			zoom(event.start, event.end);
			return;
		} // end function

		protected function zoomScrollbar():void
		{
			if (_chartScrollbar)
			{
				if (_updateScrollbar)
				{
					if (_categoryAxis.parseDates)
					{
					}
					if (!_categoryAxis.equalSpacing)
					{
						_chartScrollbar.timeZoom(_startTime, _endTime);
					}
					else
					{
						_chartScrollbar.zoom(_start, _end);
					}
					_updateScrollbar=true;
				}
			}
			return;
		} // end function

		public function get categoryField():String
		{
			return _categoryField;
		} // end function

		override protected function mouseWheelHandler(event:MouseEvent):void
		{
			var _loc_2:Number=NaN;
			var _loc_3:Number=NaN;
			if (_chartScrollbar)
			{
				if (!_mouseWheelHandled)
				{
					_chartScrollbar.stopTween();
					_updateScrollbar=true;
					if (_categoryAxis.parseDates)
					{
					}
					if (!_categoryAxis.equalSpacing)
					{
						_loc_2=_categoryAxis.minDuration;
						if (!isNaN(_chartScrollbar.mouseWheelStep))
						{
							_loc_2=_chartScrollbar.mouseWheelStep;
						}
						if (event.ctrlKey)
						{
							if (event.delta > 0)
							{
								zoom(_startTime - _loc_2, _endTime + _loc_2);
							}
							else if (_endTime - _startTime > _loc_2)
							{
								zoom(_startTime + _loc_2, _endTime - _loc_2);
							}
						}
						else if (event.delta < 0)
						{
							if (_endTime < _lastTime)
							{
								zoom(_startTime + _loc_2, _endTime + _loc_2);
							}
						}
						else if (_startTime > _firstTime)
						{
							zoom(_startTime - _loc_2, _endTime - _loc_2);
						}
					}
					else
					{
						_loc_3=_chartDataProvider.length - 1;
						if (event.ctrlKey)
						{
							if (event.delta > 0)
							{
								zoom((_start - 1), (_end + 1));
							}
							else if (_end - _start > 1)
							{
								zoom((_start + 1), (_end - 1));
							}
						}
						else if (event.delta < 0)
						{
							if (_end < _loc_3)
							{
								zoom((_start + 1), (_end + 1));
							}
						}
						else if (_start > 0)
						{
							zoom((_start - 1), (_end - 1));
						}
					}
				}
				_mouseWheelHandled=true;
				callLater(resetMouseWheel);
			}
			return;
		} // end function

		public function get endIndex():Number
		{
			return _end;
		} // end function

		override public function get dataProvider():Object
		{
			return _dataProvider;
		} // end function

		public function getCategoryIndexByValue(param1:String):Number
		{
			var _loc_3:Number=NaN;
			var _loc_2:*=_chartDataProvider.length;
			var _loc_4:Number=0;
			while (_loc_4 < _loc_2)
			{

				if (_chartDataProvider.getItemAt(_loc_4).category == param1)
				{
					_loc_3=_loc_4;
				}
				_loc_4=_loc_4 + 1;
			}
			return _loc_3;
		} // end function

		override protected function updateMasks():void
		{
			super.updateMasks();
			_columnsMask.x=_marginLeft;
			_columnsMask.y=_marginTop;
			var _loc_1:*=_plotAreaWidth;
			var _loc_2:*=_plotAreaHeight;
			if (_rotate)
			{
				_loc_2=_loc_2 + 1;
				_labelsMask.y=_marginTop;
				_labelsMask.height=_plotAreaHeight;
			}
			else
			{
				_loc_1=_loc_1 + 1;
			}
			_columnsMask.setSize(_loc_1, _loc_2, _dx, _dy);
			return;
		} // end function

		public function get categoryAxis():CategoryAxis
		{
			return _categoryAxis;
		} // end function

		override protected function setAxisRotation(param1:ValueAxis):void
		{
			param1.rotate=_rotate;
			return;
		} // end function

		public function resetZoom():void
		{
			_start=NaN;
			_end=NaN;
			return;
		} // end function

		override protected function updateScrollbars():void
		{
			if (_chartScrollbar)
			{
				if (_scrollbarPosition == "top")
				{
					if (_rotate)
					{
						_chartScrollbar.y=_marginTop;
						_chartScrollbar.x=_marginLeft - _scrollbarHeight;
					}
					else
					{
						_chartScrollbar.y=_marginTop - _scrollbarHeight + _dy;
						_chartScrollbar.x=_marginLeft + _dx;
					}
				}
				else if (_rotate)
				{
					_chartScrollbar.y=_marginTop + _dy;
					_chartScrollbar.x=_marginLeft + _plotAreaWidth + _dx;
				}
				else
				{
					_chartScrollbar.y=_marginTop + _plotAreaHeight + 1;
					_chartScrollbar.x=_marginLeft;
				}
				if (_rotate)
				{
					_chartScrollbar.height=_plotAreaHeight + 1;
				}
				else
				{
					_chartScrollbar.width=_plotAreaWidth + 1;
				}
				_chartScrollbar.mainCategoryAxis=_categoryAxis;
			}
			return;
		} // end function

		protected function indexZoom(param1:Number, param2:Number):void
		{
			var _loc_3:Number=NaN;
			if (!isNaN(_maxSelectedSeries))
			{
				if (param2 != _end)
				{
					if (param2 - param1 > _maxSelectedSeries)
					{
						param1=param2 - _maxSelectedSeries;
						_updateScrollbar=true;
					}
				}
				if (param1 != _start)
				{
					if (param2 - param1 > _maxSelectedSeries)
					{
						param2=param1 + _maxSelectedSeries;
						_updateScrollbar=true;
					}
				}
			}
			if (param1 == _start)
			{
			}
			if (param2 != _end)
			{
				_loc_3=_chartDataProvider.length - 1;
				if (isNaN(param1))
				{
					param1=0;
					if (!isNaN(_maxSelectedSeries))
					{
						param1=_loc_3 - _maxSelectedSeries;
					}
				}
				if (isNaN(param2))
				{
					param2=_loc_3;
				}
				if (param2 < param1)
				{
					param2=param1;
				}
				if (param2 > _loc_3)
				{
					param2=_loc_3;
				}
				if (param1 > _loc_3)
				{
					param1=_loc_3 - 1;
				}
				if (param1 < 0)
				{
					param1=0;
				}
				_start=param1;
				_end=param2;
				_categoryAxis.zoom(_start, _end);
				zoomAxesAndGraphs();
				zoomScrollbar();
				if (param1 == 0)
				{
				}
				if (param2 != (_dataProvider.length - 1))
				{
					if (_zoomOutButton.label)
					{
						_zoomOutButton.visible=true;
					}
				}
				else
				{
					_zoomOutButton.visible=false;
				}
				callLater(dispatchIndexZoomEvent);
			}
			return;
		} // end function

		protected function countColumns():Number
		{
			var _loc_4:AmGraph=null;
			var _loc_5:ValueAxis=null;
			var _loc_6:Boolean=false;
			var _loc_7:Number=NaN;
			var _loc_9:String=null;
			var _loc_1:Number=0;
			var _loc_2:*=_valueAxes.length;
			var _loc_3:*=_graphs.length;
			var _loc_8:Number=0;
			while (_loc_8 < _loc_2)
			{

				_loc_5=_valueAxes[_loc_8];
				_loc_9=_loc_5.stackType;
				if (_loc_9 != "100%")
				{
				}
				if (_loc_9 == "regular")
				{
					_loc_6=false;
					_loc_7=0;
					while (_loc_7 < _loc_3)
					{

						_loc_4=_graphs[_loc_7];
						if (!_loc_4.hidden)
						{
							if (_loc_4.valueAxis == _loc_5)
							{
							}
							if (_loc_4.type == "column")
							{
								if (!_loc_6)
								{
								}
								if (_loc_4.stackable)
								{
									_loc_1=_loc_1 + 1;
									_loc_6=true;
								}
								if (!_loc_4.stackable)
								{
									_loc_1=_loc_1 + 1;
								}
								_loc_4.columnIndex=_loc_1 - 1;
							}
						}
						_loc_7=_loc_7 + 1;
					}
				}
				if (_loc_9 != "none")
				{
				}
				if (_loc_9 == "3d")
				{
					_loc_7=0;
					while (_loc_7 < _loc_3)
					{

						_loc_4=_graphs[_loc_7];
						if (!_loc_4.hidden)
						{
							if (_loc_4.valueAxis == _loc_5)
							{
							}
							if (_loc_4.type == "column")
							{
								_loc_4.columnIndex=_loc_1;
								_loc_1=_loc_1 + 1;
							}
						}
						_loc_7=_loc_7 + 1;
					}
				}
				_loc_8=_loc_8 + 1;
			}
			if (_loc_9 == "3d")
			{
				_loc_8=0;
				while (_loc_8 < _loc_3)
				{

					_loc_4=_graphs[_loc_8];
					_loc_4.depthCount=_loc_1;
					_loc_8=_loc_8 + 1;
				}
				_loc_1=1;
			}
			return _loc_1;
		} // end function

		override protected function handleScrollbarZoom(event:SerialChartEvent):void
		{
			_updateScrollbar=false;
			zoom(event.start, event.end);
			return;
		} // end function

		override public function unhighlightGraph():void
		{
			super.unhighlightGraph();
			var _loc_1:*=_columnsArray.length;
			var _loc_2:Number=0;
			while (_loc_2 < _loc_1)
			{

				_columnsArray[_loc_2].column.alpha=1;
				_loc_2=_loc_2 + 1;
			}
			return;
		} // end function

		public function set rotate(param1:Boolean):void
		{
			_rotate=param1;
			invalidateMargins();
			invalidateDisplayList();
			return;
		} // end function

		protected function delayedZoomout():void
		{
			_updateScrollbar=true;
			zoom(undefined, undefined);
			return;
		} // end function

		public function zoom(param1:Number, param2:Number):void
		{
			if (_categoryAxis.parseDates)
			{
			}
			if (!_categoryAxis.equalSpacing)
			{
				timeZoom(param1, param2);
			}
			else
			{
				indexZoom(param1, param2);
			}
			return;
		} // end function

		protected function dispatchTimeZoomEvent():void
		{
			var _loc_1:*=new SerialChartEvent(SerialChartEvent.ZOOMED);
			_loc_1.startDate=new Date(_startTime);
			_loc_1.endDate=new Date(_endTime);
			_loc_1.startIndex=_start;
			_loc_1.endIndex=_end;
			_loc_1.startValue=_categoryAxis.formatDate(_loc_1.startDate);
			_loc_1.endValue=_categoryAxis.formatDate(_loc_1.endDate);
			dispatchEvent(_loc_1);
			return;
		} // end function

		public function set zoomOutOnDataUpdate(param1:Boolean):void
		{
			_zoomOutOnDataUpdate=param1;
			return;
		} // end function

		protected function zoomAxesAndGraphs():void
		{
			var _loc_3:ValueAxis=null;
			var _loc_4:AmGraph=null;
			var _loc_5:TrendLine=null;
			Utils.removeChildren(_grid0);
			_columnsArray=new Array();
			var _loc_1:*=_valueAxes.length;
			var _loc_2:Number=0;
			while (_loc_2 < _loc_1)
			{

				_loc_3=_valueAxes[_loc_2];
				_loc_3.zoom(_start, _end);
				_loc_2=_loc_2 + 1;
			}
			_loc_1=_graphs.length;
			_loc_2=0;
			while (_loc_2 < _loc_1)
			{

				_loc_4=_graphs[_loc_2];
				_loc_4.zoom(_start, _end);
				_loc_4.validateNow();
				_loc_2=_loc_2 + 1;
			}
			_loc_1=_trendLines.length;
			_loc_2=0;
			while (_loc_2 < _loc_1)
			{

				_loc_5=_trendLines[_loc_2];
				_loc_5.invalidateDisplayList();
				_loc_2=_loc_2 + 1;
			}
			if (_chartCursor)
			{
				_chartCursor.zoom(_start, _end, _startTime, _endTime);
			}
			return;
		} // end function

		public function set scrollbarOnly(param1:Boolean):void
		{
			_scrollbarOnly=param1;
			return;
		} // end function

		protected function dispatchIndexZoomEvent():void
		{
			var _loc_1:SerialChartEvent=null;
			if (!isNaN(_start))
			{
			}
			if (!isNaN(_end))
			{
				_loc_1=new SerialChartEvent(SerialChartEvent.ZOOMED);
				_loc_1.startIndex=_start;
				_loc_1.endIndex=_end;
				_loc_1.startValue=_chartDataProvider[_start].category;
				_loc_1.endValue=_chartDataProvider[_end].category;
				if (_categoryAxis.parseDates)
				{
					_startTime=_chartDataProvider[_start].time;
					_endTime=_chartDataProvider[_end].time;
					_loc_1.startDate=new Date(_startTime);
					_loc_1.endDate=new Date(_endTime);
				}
				dispatchEvent(_loc_1);
			}
			return;
		} // end function

		public function set maxSelectedSeries(param1:Number):void
		{
			_maxSelectedSeries=param1;
			return;
		} // end function

		override protected function handleCursorChange(event:CursorEvent):void
		{
			dispatchCursorEvent(event.index);
			return;
		} // end function

		override protected function destroy():void
		{
			super.destroy();
			Utils.removeChildren(_columnsContainer);
			return;
		} // end function

		protected function addColumns():void
		{
			var _loc_1:Number=NaN;
			var _loc_4:AmGraph=null;
			var _loc_5:Array=null;
			var _loc_6:Number=NaN;
			Utils.removeChildren(_columnsContainer);
			var _loc_2:*=_graphs.length;
			_columnsArray=new Array();
			_loc_1=0;
			while (_loc_1 < _loc_2)
			{

				_loc_4=_graphs[_loc_1];
				_loc_5=_loc_4.columnsArray;
				if (_loc_5)
				{
					_loc_6=0;
					while (_loc_6 < _loc_5.length)
					{

						_columnsArray.push(_loc_5[_loc_6]);
						_loc_6=_loc_6 + 1;
					}
				}
				_loc_1=_loc_1 + 1;
			}
			_columnsArray.sortOn("depth", Array.NUMERIC);
			var _loc_3:*=_columnsArray.length;
			_loc_1=0;
			while (_loc_1 < _loc_3)
			{

				_columnsContainer.addChild(_columnsArray[_loc_1].column);
				_loc_1=_loc_1 + 1;
			}
			callLater(removeOld);
			return;
		} // end function

		protected function handleDelayedZoomToDates(event:AmChartEvent):void
		{
			this.removeEventListener(AmChartEvent.DATA_UPDATED, handleDelayedZoomToDates);
			zoomToDates(_tempStartDate, _tempEndDate);
			return;
		} // end function

		override protected function updateDisplayList(param1:Number, param2:Number):void
		{
			super.updateDisplayList(param1, param2);
			if (_previousHeight == this.height)
			{
			}
			if (_previousWidth != this.width)
			{
				addAxesListeners();
				_marginsInvalidated=false;
			}
			_previousHeight=this.height;
			_previousWidth=this.width;
			return;
		} // end function

		private static function initStyles():Boolean
		{
			var styleDeclaration:*=StyleManager.getStyleDeclaration("AmSerialChart");
			if (!styleDeclaration)
			{
				styleDeclaration=new CSSStyleDeclaration();
			}
			styleDeclaration.defaultFactory=function():void
			{
				this.columnSpacing=5;
				this.columnWidth=0.8;
				return;
			} // end function
			;
			StyleManager.setStyleDeclaration("AmSerialChart", styleDeclaration, false);
			return true;
		} // end function

	}
}
